package com.sk.bilibili.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.sk.bilibili.bean.Type;
import com.sk.bilibili.other.R;
import com.sk.bilibili.service.TypeService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
* @author 邵康
* @date 2021/11/23 18:45
*/
@CrossOrigin
@RestController
@Api(tags = "类型")
@RequestMapping("/type")
public class TypeController {

    @Autowired
    private TypeService typeService;

    @ApiOperation("add")
    @PostMapping("/add")
    public R<Void> add( Type type){
        return typeService.add(type);
    }

    @ApiOperation("deleteRes")
    @GetMapping("/delete")
    public R<Void> delete(Integer id){
        return typeService.delete(id);
    }

    @ApiOperation("update")
    @PostMapping("/update")
    public R<Void> update( Type type){
        return typeService.update(type);
    }

    @ApiOperation("pageSearch")
    @GetMapping("/page")
    public R<IPage<Type>> page( @RequestParam(defaultValue = "1") Integer page,
                                @RequestParam(defaultValue = "10") Integer size){
        return typeService.page(page,size);
    }

    @ApiOperation("获取所有类型信息")
    @GetMapping("/getAll")
    public R<List<Type>> getAll(){
        return typeService.getAll();
    }

}
